//
//  LSRThemeBottomView.m
//  BaiSiProject
//
//  Created by lshenrong on 16/7/16.
//  Copyright © 2016年 lshenrong. All rights reserved.
//

#import "LSRThemeBottomView.h"
#import "LSRThemeItem.h"
@class LSRThemeBottomView;
@interface LSRThemeBottomView()
@property (weak, nonatomic) IBOutlet UIButton *dingView;
@property (weak, nonatomic) IBOutlet UIButton *caiView;

@property (weak, nonatomic) IBOutlet UIButton *shareView;
@property (weak, nonatomic) IBOutlet UIButton *commentView;

@end
@implementation LSRThemeBottomView
- (void)awakeFromNib
{
    // iOS6属性,自动拉伸
    // 每一个View默认都会有拉伸属性,
    // 取消拉伸属性
    self.autoresizingMask = UIViewAutoresizingNone;
}


+(instancetype)bottomView
{

    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self)    owner:nil options:nil] lastObject];
    


}
//通常把需要计算的nsstring类型改为NSInteger类型，考虑到为0的时候显示文字

-(void)setItem:(LSRThemeItem *)item

{   _item=item;
    
     [self setTitleButton:self.dingView count:item.ding title:@"顶"];
     [self setTitleButton:self.caiView count:item.cai title:@"踩"];
     [self setTitleButton:self.commentView count:item.comment title:@"转发"];
     [self setTitleButton:self.shareView count:item.repost title:@"评论"];
    
    
}
-(void)setTitleButton:(UIButton *) button count:(NSInteger)count title:(NSString *)title

{
  
    
    if (count>10000)
    {
        float ct=1.0*count/10000;
        
        title=[NSString stringWithFormat:@"%.1f万",ct];
    }
    else if (count>0)
    {
    
       title=[NSString stringWithFormat:@"%ld",count];
        
    }

    [button setTitle:title forState:UIControlStateNormal];


}

@end
